package com.lgd.factoryattendance.httpService;


import com.lgd.factoryattendance.Bean.AssemblyGallery;
import com.lgd.factoryattendance.Bean.AssemblyManagement;
import com.lgd.factoryattendance.Bean.DebugLog;
import com.lgd.factoryattendance.Bean.ElectricalGalleryType;
import com.lgd.factoryattendance.Bean.ElectricalProcess;
import com.lgd.factoryattendance.Bean.FactoryAbnormalIssues;
import com.lgd.factoryattendance.Bean.FactoryDeviceManagement;
import com.lgd.factoryattendance.Bean.K3cloudBom;
import com.lgd.factoryattendance.Bean.MachineDebugInfoBean;
import com.lgd.factoryattendance.Bean.ProjectGuideInfo;
import com.lgd.factoryattendance.Bean.ProjectManagement;
import com.lgd.factoryattendance.Bean.ProjectType;
import com.lgd.factoryattendance.Bean.SysUser;
import com.lgd.factoryattendance.Bean.WorkHourStatistics;
import com.lgd.factoryattendance.httpService.httpPort.IHttpHelper;
import com.lgd.factoryattendance.httpService.httpPort.IResponse;
import com.lgd.factoryattendance.httpService.httpPort.IStringResponse;

import java.util.List;

/**
 * @Author lgd
 * @Date 2024/1/18 13:42
 */
public class API {
    private static final String TAG = "API";
    private  static IHttpHelper httpHelper;
    private  static String serverUrl = "http://192.168.3.9:8080";  //  本机测试地址

//    private  static String serverUrl = "http://111.229.152.119:8080";   // 网络测试地址
    /**
     * API组件初始化，不可static直接赋值，防止GlobalInfo未初始化造成null
     */
    public static void init(){
        IHttpHelper iHttpHelper = new HttpHelperImpl();
        httpHelper = iHttpHelper;
//        httpHelper=ServiceFactory.httpHelper;
        System.out.println("http初始化成功");
    }
    //根据 android ID 查询是否绑定设备
    public static void BindOrNotDevice(FactoryDeviceManagement factoryDeviceManagement, IStringResponse response){
        httpHelper.post(serverUrl+"/deviceManagement/deviceManagement/selectDevice",factoryDeviceManagement,response);
    }
    // 添加设备 信息
    public static void addSerialNumber(FactoryDeviceManagement factoryDeviceManagement, IStringResponse response){
        httpHelper.post(serverUrl+"/deviceManagement/deviceManagement/addSerialNumber",factoryDeviceManagement,response);
    }
    //  根据 卡片序列号/ 员工姓名 查询信息
    public static void seleceStaffInfo(SysUser sysUser, IStringResponse response){
        httpHelper.post(serverUrl+"/system/user/seleceStaffInfo",sysUser,response);
    }
    //   根据 deviceid 查找 项目，部装 ，设备信息 , 电气装配信息
    public static void getStartProject(ProjectManagement projectManagement,IStringResponse response){
        httpHelper.post(serverUrl+"/projectManagement/projectManagement/getStartProject",projectManagement,response);
    }
    //   工人上班打卡
    public static void workClockIn(WorkHourStatistics workHourStatistics,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/workClockIn",workHourStatistics,response);
    }
    public static void addWorkClockIn(WorkHourStatistics workHourStatistics,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/addWorkClockIn",workHourStatistics,response);
    }

    // 判断 今日工人是否打卡
    public static void clockInStatus(WorkHourStatistics workHourStatistics,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/clockInStatus",workHourStatistics,response);
    }
    // 获取 最新 工单数据
    public static void getLatestWorkOrder(WorkHourStatistics workHourStatistics,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/getLatestWorkOrder",workHourStatistics,response);
    }

    //  开始+ 结束 +userID 计算工时
    public static void calculateDuration(WorkHourStatistics workHourStatistics,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/calculateDuration",workHourStatistics,response);
    }
    //  下班 打卡信息上报
    public static void updateWorkHourStatistics(WorkHourStatistics w, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/updateWorkHourStatistics",w,response);
    }
    public static void editWorkHour(WorkHourStatistics w, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/editWorkHour",w,response);
    }
    // 超期原因 上报
    public static void updataOverdurInfo(AssemblyManagement a,IStringResponse response){
        httpHelper.post(serverUrl+"/assemblyManagement/assemblyManagement/updataOverdurInfo",a,response);
    }
    //   查询 超期工单
    public static void getOverdueAssembly(AssemblyManagement a,IStringResponse response){
        httpHelper.post(serverUrl+"/assemblyManagement/assemblyManagement/getOverdueAssembly",a,response);
    }
    // 查询 所有项目
    public static void findProjectName(ProjectManagement p, IStringResponse response){
        httpHelper.post(serverUrl+"/projectManagement/projectManagement/findProjectName",p,response);
    }
    //   根据 userID 查找异常工单信息
    public static void getAbnormalClock(WorkHourStatistics w, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/getAbnormalClock",w,response);
    }
    // 根据 acode  查找
    public static void findAssByAcode(AssemblyManagement a, IStringResponse response){
        httpHelper.post(serverUrl+"/assemblyManagement/assemblyManagement/findAssByAcode",a,response);
    }
    // 超期原因
    public static void abnormalCause(FactoryAbnormalIssues f, IStringResponse response){
        httpHelper.post(serverUrl+"/abnormalIssues/abnormalIssues/abnormalCause",f,response);
    }
    // 本月时长
    public static void selectDurationList(WorkHourStatistics w, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/selectDurationList",w,response);
    }
    // 添加 调试信息
    public static void addDebugLog(DebugLog debugLog, IStringResponse response){
        httpHelper.post(serverUrl+"/debugLog/debugLog/addDebugLog",debugLog,response);
    }
    //  查询 调试日志信息
    public static void selectDebugLog(DebugLog debugLog,IStringResponse response){
        httpHelper.post(serverUrl+"/debugLog/debugLog/selectDebugLog",debugLog,response);
    }
    //  修改 调试日志
    public static void updaterDebugLog (DebugLog debugLog, IStringResponse response){
        httpHelper.post(serverUrl+"/debugLog/debugLog/updaterDebugLog",debugLog,response);
    }

    // 获取  图库PDF 信息
    public static void getGallery(AssemblyGallery a ,IStringResponse response){
        httpHelper.post(serverUrl+"/gallery/gallery/getGallery", a, response);
    }
    //  获取 PDF 文件
    public static void selectAllByGallery(AssemblyGallery a,IStringResponse response){
        httpHelper.post(serverUrl+"/gallery/gallery/selectAllByGallery",a,response);
    }
    // 获取 电气图库类型
    public static void selectGalleryType(ElectricalGalleryType e,IStringResponse response){
        httpHelper.post(serverUrl+"/electricalGalleryType/electricalGalleryType/selectGalleryType",e,response);
    }
    //  部门下拉框 信息
    public static void findDeptByDu(IResponse response){
        httpHelper.get(serverUrl+"/system/dept/findDeptByDu",response);
    }
    /// 下班
    public static void updateWorkOrder(WorkHourStatistics w ,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/updateWorkOrder",w,response);
    }

    //  获取项目 分类类型
    public static void projectType(IResponse response){
        httpHelper.get(serverUrl+"/projectManagement/projectManagement/getStartProjectClassification",response);
    }
    // 获取项目信息，机械部装，电气部装
    public static void getStartProjectInfo(ProjectType projectType,IStringResponse response){
        httpHelper.post(serverUrl+"/projectManagement/projectManagement/getStartProjectInfo",projectType,response);
    }
    // 根据 项目id 查找部装信息
    public static void selectAssemblyById(ProjectManagement p, IStringResponse response){
        httpHelper.post(serverUrl+"/projectManagement/projectManagement/selectAssemblyById",p ,response);
    }
    // 根据 workID  删除
    public static void delectWorkHour(WorkHourStatistics w,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/delectWorkHour",w,response);
    }
    // 查找 电气部装信息
    public static void getElectricalProcess (ElectricalProcess electricalProcess, IStringResponse response){
        httpHelper.post(serverUrl+"/electricalProcess/electricalProcess/getElectricalProcess",electricalProcess, response);
    }
    // 条件 查询 项目 A码
    public static void selectProjectCode(ProjectType projectType, IStringResponse response){
        httpHelper.post(serverUrl+"/projectManagement/projectManagement/selectProjectCode", projectType, response);
    }
    //   批量添加 工单
    public static void addWorkClockInBatch(List<WorkHourStatistics> workHourStatisticsList ,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/addWorkClockInBatch", workHourStatisticsList, response);
    }
    // 批量添加 调试信息 和 更新 工时
    public static void AddDebugLogAndUpdaterWorkHours(DebugLog debugLog ,IStringResponse response){
        httpHelper.post(serverUrl+"/debugLog/debugLog/AddDebugLogAndUpdaterWorkHours", debugLog, response);
    }
    public static void AddDebugLogAndUpdaterWorkHours2(DebugLog debugLog ,IStringResponse response){
        httpHelper.post(serverUrl+"/debugLog/debugLog/AddDebugLogAndUpdaterWorkHours2", debugLog, response);
    }

    //  查询 指导书 信息
    public static void selectGuideInfoByEntity (ProjectGuideInfo projectGuideInfo, IStringResponse response){
        httpHelper.post(serverUrl+"/projectGuideInfo/projectGuideInfo/selectGuideInfoByEntity", projectGuideInfo, response);
    }

    //  根据 A码 查询 金蝶 部装列表
    public static void getAssemblyListByCode(K3cloudBom k3cloudBom, IStringResponse response){
        httpHelper.post(serverUrl+"/k3cloudBom/k3cloudBom/getAssemblyListByCode", k3cloudBom, response);
    }

    /**
     *  projectId , assemblyName 查询 BOM 清单
     */
    public static void getBomListByCodeAndAssembly(K3cloudBom k3cloudBom, IStringResponse response){
        httpHelper.post(serverUrl+"/k3cloudBom/k3cloudBom/getBomListByCodeAndAssembly", k3cloudBom, response);
    }

}
